package 数据结构上

import scala.collection.mutable.ListBuffer

object ListBufferDemo01 {
  def main(args: Array[String]): Unit = {
    val list1 = ListBuffer(1, 2, 3, 4)
    for (item <- list1) {
      print(item)
    }
    val list2 = new ListBuffer[Int]
    list2 += 2
    list2.append(5)
    /*添加多个元素*/
    list2 ++= list1
    print(list2)

    var list3 = list2 :+ 5
    print(list3)

    /*删除,按照索引*/
    list3.remove(0)
  }

}
